<?php
$id = $_GET['id'];
global $wpdb;
$part = $wpdb->get_row("select img,parts.name as name,parts_type.name as part_name,parts.update_time from parts left join parts_type on parts.parts_type_id = parts_type.id where parts.id = $id");
if(!$part) {
    wp_redirect( home_url(), 301 );
}
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title><?php echo $part->name; ?></title>
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="bookmark" href="/favicon.ico" type="image/x-icon"　/>
    <?php wp_head(); ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>?ver=1">
</head>

<body>
<header>
    <?php ?>
    <!--主导航-->
    <nav id="top-nav-wraper" class="container">
        <div class="menu-icon">
				<span class="fas">
					<img src="<?php echo get_stylesheet_directory_uri() . '/images/fa-menu.png'; ?>">
				</span>
        </div>
        <a class="logo" href="<?php echo home_url(); ?>"><?php jiangqie_site_logo() ?></a>
        <?php
        $menus = get_nav_menu_locations();
        if (isset($menus['main-menu'])) {
            wp_nav_menu([
                'theme_location' => 'main-menu',
                'container' => 'div',
                'container_class' => 'nav-box',
                'menu_class' => 'nav-items',
            ]);
        }
        ?>
        <div class="search-icon">
				<span class="fas">
					<img src="<?php echo get_stylesheet_directory_uri() . '/images/fa-search.png'; ?>">
				</span>
        </div>
        <div class="cancel-icon">
				<span class="fas">
					<img src="<?php echo get_stylesheet_directory_uri() . '/images/fa-close.png'; ?>">
				</span>
        </div>
        <form method="get" action="<?php bloginfo('url'); ?>/">
            <input type="search" class="search-data" placeholder="输入搜索内容" value="" name="s" id="s" required style="color:black;">
            <button type="submit">搜索</button>
        </form>
    </nav>
</header>

<?php
wp_dequeue_script('jq-archive-script');

//get_header();

?>

<?php //////////////////////正文开始//////////////////// ?>
    <style type="text/css">
        .head .avatar {
            min-height: 120px;
            display: inline-block;
            width: 100%;
        }
        .head .avatar img {
            border-radius: 2px;
            display: block;
            margin: auto;
            width: 130px;
        }
        .details {
            padding-left: 5px;
        }
        .details .part-name h1{
            font-size: 1.7em;
            margin: 5px 25px 0 0;
            color: #222;
        }
        .details ul li{
            border: none;
            margin: 13px 5px 5px 0;
            font-size: 14px;
            display: inline-block;
        }
    </style>

    <?php

    if(is_open_cos()){
        $site_url = get_cos_domain();
    }else{
        $site_url = site_url();
    }
    ?>
    <!--主内容区-->
    <div class="main-body mt-20">
        <div class="container">
            <?php jiangqie_breadcrumbs(); ?>

            <!--      基本信息      -->
            <div class="pure-g row d-flex flex-wrap" style="margin-bottom: 15px;">
                <div class="pure-u-md-1-4 pure-u-sm-1-3 pure-u-tiny-1-3 head">
                    <div class="avatar"><img src="<?php echo $site_url.$part->img; ?>"></div>
                </div>
                <div class="pure-u-md-3-4 pure-u-sm-2-3 pure-u-tiny-2-3 details">
                    <div class="part-name">
                        <h1><?php echo $part->name; ?></h1>
                    </div>
                    <ul>
                        <li>类型：<a href="/parts/frame"><?php echo $part->part_name; ?></a></li>
                        <li></li>
                        <li>更新日期：<?php echo $part->update_time; ?></li>
                    </ul>
                </div>
            </div>


<!--            <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
<!--            <!-- 【横】长方形广告 -->
<!--            <ins class="adsbygoogle"-->
<!--                 style="display:block"-->
<!--                 data-ad-client="ca-pub-6243451787655828"-->
<!--                 data-ad-slot="4209566881"-->
<!--                 data-ad-format="auto"-->
<!--                 data-full-width-responsive="true"></ins>-->
<!--            <script>-->
<!--                (adsbygoogle = window.adsbygoogle || []).push({});-->
<!--            </script>-->


            <!--      相关配置      -->
            <?php
            global $wpdb;
            $fpv_ids = $wpdb->get_results("select fpv_id from fpv_parts where parts_id = {$id} order by update_time DESC");
            ?>
            <h1 style="font-size: 30px;margin: 50px 0 10px;">相关配置</h1>
            <div class="pure-g act-grid">
                <?php foreach ($fpv_ids as $postid) {
                        $post = get_post($postid->fpv_id);
                ?>
                    <div class="pure-sm-1 pure-u-md-1-2 pure-u-lg-1-3 grid-item" style="margin-left: -3px">
                        <div class="grid-image" style="background: url(<?php echo replace_cos_url(get_the_post_thumbnail_url($post->ID)); ?>) no-repeat center center;background-size: cover !important;padding-bottom: 250px;">
                            <a href="<?php echo get_post_permalink($post->ID); ?>" class="grid-link"><span class="act-title"><?php echo $post->post_title; ?></span>
                                <!--                                <div class="act-user">by OptimaZe</div>-->
                            </a>
                        </div>

                        <div class="act-footer-left act-age"><?php echo jiangqie_time_ago(get_gmt_from_date($post->post_modified_gmt)); ?></div>
                        <div class="act-footer">
                            <a href="#"><i class="icon-heart" aria-hidden="true"></i><?php jiangqie_post_detail_view_count(); ?></a>
                            <a href="#"><i class="icon-ei-chart" aria-hidden="true"></i><?php jiangqie_post_detail_thumbup_count(); ?></a>&nbsp;
                        </div>
                    </div>
                <?php } ?>
            </div>

            <?php
            wp_reset_query();
            ?>
        </div>

    </div>


    <!--components-->
    <link rel='stylesheet' id='build-css'  href='<?php echo site_url(); ?>/wp-content/themes/jiangqie/css/purecss.css?ver=5.6' type='text/css' media='all' />
    <link rel='stylesheet' id='build-css'  href='<?php echo site_url(); ?>/wp-content/themes/jiangqie/css/build.css?ver=5.6' type='text/css' media='all' />

    <script type="text/javascript">
        var $ = jQuery.noConflict();//解除wordpress jquery限制

    </script>

<?php get_footer(); ?>